package com.example.demo.jpa.customer.constants;

public enum Sex {

    MALE(0,"男"),
    FEMALE(1,"女"),
    UNKNOWN(99,"unknown");

    private  int code;
    private final String name;

    Sex(int code, String name){
        this.code = code;
        this.name=name;
    }

    public static Sex getSexByCode(int code){
        for (Sex tmp: Sex.values()){
            if (tmp.code == code)
                return tmp;
        }
        return UNKNOWN;
    }
}
